package cn.yong.service;

import cn.yong.dao.ProjectDao;
import cn.yong.entity.Project;
import org.hibernate.HibernateException;
import org.hibernate.Transaction;

public class ProjectService {
    private ProjectDao projDao = new ProjectDao();

    public void addNewProject(Project proj) {
        Transaction tx = null;
        try {
            tx = projDao.currentSession().beginTransaction();
            projDao.save(proj);
            tx.commit(); // 鎻愪氦浜嬪姟
        } catch (HibernateException e) {
            e.printStackTrace();
            if (tx != null)
                tx.rollback(); // 鍥炴粴浜嬪姟
        }
    }
}
